/**
* 
* Sonde system specific sonde for processor 
* Copyright (c) 2009 Ecole Centrale de Nantes IRCCyN  
* 
* see <a href="{@docRoot}/Documentation/sonde.html"> for more information</a>
* 
* @author: Urunuela Richard
* @version 3.2
*/
package report;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Vector;

import storm.ISimulationKernel;
import storm.Processors.Processor;
import storm.Tasks.Task;

public class processors extends sonde {

	private ArrayList listeProcessor;
	
	/**
	 * new sonde
	 * @param theOutPut
	 * @param kernel
	 */
	public processors(output theOutPut, ISimulationKernel kernel) {
		this.theOutPut = theOutPut;
		this.listeProcessor = kernel.getTasksListeManager().getALLProcessors();
		this.theOutPut.appendSection("Processors");
	}
	/**
	 *  Parse specific  command from report file
	 *  internal data is specific onwn field (not calculate) 
	 */
	public void internalData(String commande) {
		if (commande.compareToIgnoreCase("info")==0){
			Iterator i  = this.listeProcessor.iterator();
			while(i.hasNext()){
				Processor crt = (Processor) i.next();
				this.theOutPut.addligne(crt.getName()+ " : " + crt.getClass().getName());
				
			}
		}
		if (commande.compareToIgnoreCase("trace")==0){
			Iterator i  = this.listeProcessor.iterator();
			while(i.hasNext()){
				Processor crt = (Processor) i.next();
				this.theOutPut.beginTab(crt.getName(),4);
				classSonde sonde = crt.getMySonde();
				if (sonde ==null){
					this.theOutPut.beginTab("Use trace = 1 in  XML file to use trace",4);
				}
				else{
					for (int j = 0; j < sonde.getNombreligne();j++){
						Vector vec = sonde.getligne(j);
						this.theOutPut.add(vec);
					}
				}
				
			}
			
		}
	}

}
